Here is a step-by-step guide to installing and configuring Apache Cassandra and executing core NoSQL operations using CQL (Cassandra Query Language).

Using Docker is the fastest, cleanest, and most reliable way to set up Cassandra locally without messy Java path configurations.

Step 1: Install and Run Cassandra (via Docker)
If you have Docker installed on your machine, run the following command in your terminal to download and start a single-node Cassandra cluster:

Bash
docker run --name cassandra-node -p 9042:9042 -d cassandra:latest
-p 9042:9042: Exposes Cassandra's native transport port so local clients or shells can connect.

-d: Runs the container in the background.

To check if the container is running and healthy, run:

Bash
docker ps
Step 2: Access the Interactive Shell (cqlsh)
Cassandra provides an interactive command-line tool called cqlsh (Cassandra Query Language Shell) to interact with the database.

Enter the running Docker container's terminal and open cqlsh:

Bash
docker exec -it cassandra-node cqlsh
You should see a prompt like this:

Plaintext
Connected to Test Cluster at 127.0.0.1:9042
[cqlsh 6.1.0 | Cassandra 4.x.x | CQL spec 3.4.x | Native protocol v5]
Use HELP for help.
cqlsh> 
Step 3: Executing NoSQL Operations (CQL)
Cassandra uses CQL, which looks very similar to SQL, but under the hood, it is structured around a distributed column-family NoSQL architecture.

1. Create a Keyspace (Database)
A Keyspace is equivalent to a database in relational systems. It defines how data is replicated across nodes.

SQL
CREATE KEYSPACE university_db 
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
2. Switch to the Keyspace
SQL
USE university_db;
3. Create a Table (Column Family)
In Cassandra, tables must explicitly define a Primary Key, which consists of a Partition Key (determines which node stores the data) and optional Clustering Keys (determines sorting order within the partition).

SQL
CREATE TABLE students (
    roll_no int,
    name text,
    department text,
    gpa float,
    PRIMARY KEY (roll_no)
);
4. Insert Data (Write Operation)
NoSQL databases like Cassandra are optimized for high-speed writes.

SQL
INSERT INTO students (roll_no, name, department, gpa) VALUES (101, 'Alice Smith', 'Computer Science', 3.8);
INSERT INTO students (roll_no, name, department, gpa) VALUES (102, 'Bob Jones', 'Information Technology', 3.4);
INSERT INTO students (roll_no, name, department, gpa) VALUES (103, 'Charlie Brown', 'Data Science', 3.9);
5. Read Data (Query Operation)
Select all records: (ALLOW FILTERING is required in Cassandra when querying by non-primary key columns, though discouraged in production for performance reasons).

SQL
SELECT * FROM students;
Select by Primary Key (Fast Lookup):

SQL
SELECT name, gpa FROM students WHERE roll_no = 101;
6. Update Data
In Cassandra, an INSERT and an UPDATE act essentially the same way (known as an upsert). If the primary key exists, it updates the columns; if not, it creates a new row.

SQL
UPDATE students SET gpa = 3.95 WHERE roll_no = 101;
7. Delete Data
SQL
DELETE FROM students WHERE roll_no = 102;
Verify the deletion by running SELECT * FROM students;.